package it.yuzuojian.com.controller;


import it.yuzuojian.com.javaBean.Comment1;
import it.yuzuojian.com.service.Comment1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

@Controller
public class Comment1Controller{
    @Autowired
    private Comment1Service comment1Service;
    @PostMapping("/comment/add")
    public String add(Comment1 comment1){

        if(comment1.getAdmin()==null){
            comment1.setAdmin(false);
        }
        comment1.setCreateTime(new Date());
        comment1Service.add(comment1);
        System.out.println(comment1);
        return "articleInfo :: commentList";
    }

    @GetMapping("/a")
    public String a(Model model, String name){

        System.out.println(name);
        model.addAttribute("name",name);
        return "a";
    }
}
